package com.angel.web.app;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.angel.core.base.JsonEntity;
import com.angel.core.util.JsonUtil;
import com.angel.health.BuzBluetooth;
import com.angel.provider.health.BuzBluetoothProvider;

/** 
* @author 作者姓名  cheng
* @version 
* 创建时间：2016年10月27日 下午6:21:21 
* 类说明  app蓝牙数据传输
*/
@Controller
@RequestMapping("app/bluetooth")
public class AppBluetoothController {
	
	@Autowired
	private BuzBluetoothProvider bbtProvider;
	
	/**
	 * 
	 * @param bbt
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "index", produces = "application/json; charset=utf-8")
	public String index(BuzBluetooth bbt){
		if(bbt.getCustomerId() == null){
			return JsonUtil.toJson(new JsonEntity("-1","参数不正确"));
		}
		List<Map<String, Object>> list = bbtProvider.findAllForApp(bbt);
		return JsonUtil.toJson(new JsonEntity("200",list));
	} 
	
	@ResponseBody
	@RequestMapping(value = "addBluetooth", produces = "application/json; charset=utf-8")
	public String addBluetooth(BuzBluetooth bbt){
		if(bbt.getCustomerId() == null){
			return JsonUtil.toJson(new JsonEntity("-1","参数不正确"));
		}
		bbt.setCreateTime(new Date());
		bbtProvider.insert(bbt);
		return JsonUtil.toJson(new JsonEntity("200","上传成功"));
	}
}
